package pl.wroc.pwr.psi.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import pl.wroc.pwr.psi.entity.Synonim;
import pl.wroc.pwr.psi.repository.SlowoKluczoweRepository;
import pl.wroc.pwr.psi.repository.SynonimRepository;

/**
 * 
 * @author wposlednicka
 *
 */
@Service
public class SynonimService {
	
	@Autowired
	private SynonimRepository synonimRepository;
	
	@Autowired
	private SlowoKluczoweRepository slowoKluczoweRepository;
	
	public Synonim findSynonimById(Integer id){
		return synonimRepository.findOne(id);
	}
	
	public void deleteSynonimById(Integer id){
		
		Synonim synonim = synonimRepository.findOne(id);
		synonim.setSlowoKluczowe(null);
		synonimRepository.save(synonim);
		synonimRepository.delete(id);
	}	
	
	
}
